package com.fjnldx.mes.controller.dataDictionary;

import com.fjnldx.mes.domain.domainReq.DeleteReq;
import com.fjnldx.mes.domain.domainRes.Result;
import com.fjnldx.mes.domain.pojo.FzyDictionaryData;
import com.fjnldx.mes.domain.pojo.FzyDictionaryDataList;
import com.fjnldx.mes.service.dataDictionary.DataDictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/dataDictionary")
@Api(value = "数据字典", tags = "数据字典")
public class DataDictionaryController {

    @Resource
    private DataDictionaryService dataDictionaryService;

    @PostMapping("/queryDataDictionary")
    @ApiOperation(value = "查询数据字典", notes = "查询数据字典")
    public Result queryDataDictionary(@RequestBody FzyDictionaryData fzyDictionaryData) throws Exception {
        return dataDictionaryService.queryDataDictionary(fzyDictionaryData);
    }

    @PostMapping("/queryDataDictionaryList")
    @ApiOperation(value = "查询数据字典列表", notes = "查询数据字典列表")
    public Result queryDataDictionaryList(@RequestBody FzyDictionaryDataList fzyDictionaryDataList) throws Exception {
        return dataDictionaryService.queryDataDictionaryList(fzyDictionaryDataList);
    }

    //@PostMapping("/insertDataDic")
    //@ApiOperation(value = "新增数据字典", notes = "新增数据字典")
    //public Result insertDataDic(@RequestBody FzyDictionaryData data) throws Exception {
    //    return dataDictionaryService.insertDataDic(data);
    //}

    @PostMapping("/insertDataDicList")
    @ApiOperation(value = "新增数据字典成员列表", notes = "新增数据字典成员列表")
    public Result insertDataDicList(@RequestBody FzyDictionaryDataList data) throws Exception {
        return dataDictionaryService.insertDataDicList(data);
    }

    //@PostMapping("/deleteDataDic")
    //@ApiOperation(value = "删除数据字典", notes = "删除数据字典")
    //public Result deleteDataDic(@RequestBody DeleteReq delete) throws Exception {
    //    return dataDictionaryService.deleteDataDic(delete.getArray());
    //}

    @PostMapping("/deleteDataDicList")
    @ApiOperation(value = "删除数据字典成员列表", notes = "删除数据字典成员列表")
    public Result deleteDataDicList(@RequestBody DeleteReq delete) throws Exception {
        return dataDictionaryService.deleteDataDicList(delete.getArray());
    }

    //@PostMapping("/updateDataDic")
    //@ApiOperation(value = "更新数据字典", notes = "更新数据字典")
    //public Result updateDataDic(@RequestBody FzyDictionaryData data) throws Exception {
    //    return dataDictionaryService.updateDataDic(data);
    //}

    @PostMapping("/updateDataDicList")
    @ApiOperation(value = "更新数据字典成员列表", notes = "更新数据字典成员列表")
    public Result updateDataDicList(@RequestBody FzyDictionaryDataList data) throws Exception {
        return dataDictionaryService.updateDataDicList(data);
    }
}
